package cn.gson.springboot.model.pjos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Zproduct {
    private int productId;
    private String productName;
    private String prModel;
    private String prImgpath;
    private Zproductbrand zproductbrandByPdId;
    private Zproductcategory zproductcategoryByPcId;
   /* private Zproductside zproductsideByPsId;*/
    private Collection<Zproductside> zproductsidesByProductId;

    @Id
    @Column(name = "product_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getProductId() {
        return productId;
    }

    public void setProductId(int productId) {
        this.productId = productId;
    }

    @Basic
    @Column(name = "product_name")
    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    @Basic
    @Column(name = "pr_model")
    public String getPrModel() {
        return prModel;
    }

    public void setPrModel(String prModel) {
        this.prModel = prModel;
    }

    @Basic
    @Column(name = "pr_imgpath")
    public String getPrImgpath() {
        return prImgpath;
    }

    public void setPrImgpath(String prImgpath) {
        this.prImgpath = prImgpath;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Zproduct zproduct = (Zproduct) o;
        return productId == zproduct.productId &&
                Objects.equals(productName, zproduct.productName) &&
                Objects.equals(prModel, zproduct.prModel) &&
                Objects.equals(prImgpath, zproduct.prImgpath);
    }

    @Override
    public int hashCode() {
        return Objects.hash(productId, productName, prModel, prImgpath);
    }

    @ManyToOne
    @JoinColumn(name = "pd_id", referencedColumnName = "pd_id")
    public Zproductbrand getZproductbrandByPdId() {
        return zproductbrandByPdId;
    }

    public void setZproductbrandByPdId(Zproductbrand zproductbrandByPdId) {
        this.zproductbrandByPdId = zproductbrandByPdId;
    }

    @ManyToOne
    @JoinColumn(name = "pc_id", referencedColumnName = "pc_id")
    public Zproductcategory getZproductcategoryByPcId() {
        return zproductcategoryByPcId;
    }

    public void setZproductcategoryByPcId(Zproductcategory zproductcategoryByPcId) {
        this.zproductcategoryByPcId = zproductcategoryByPcId;
    }

    /*@ManyToOne
    @JoinColumn(name = "ps_id", referencedColumnName = "ps_id")
    public Zproductside getZproductsideByPsId() {
        return zproductsideByPsId;
    }

    public void setZproductsideByPsId(Zproductside zproductsideByPsId) {
        this.zproductsideByPsId = zproductsideByPsId;
    }
*/

    @OneToMany(mappedBy = "zproductByProductId")
    public Collection<Zproductside> getZproductsidesByProductId() {
        return zproductsidesByProductId;
    }

    public void setZproductsidesByProductId(Collection<Zproductside> zproductsidesByProductId) {
        this.zproductsidesByProductId = zproductsidesByProductId;
    }

    @Override
    public String toString() {
        return "Zproduct{" +
                "productId=" + productId +
                ", productName='" + productName + '\'' +
                ", prModel='" + prModel + '\'' +
                ", prImgpath='" + prImgpath + '\'' +
                ", zproductbrandByPdId=" + zproductbrandByPdId +
                ", zproductcategoryByPcId=" + zproductcategoryByPcId +
                ", zproductsidesByProductId=" + zproductsidesByProductId +
                '}';
    }
}
